package com.lgc.algorithm.other;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int[] arr = {10, 2, 8, 1, 2, 3, 5, 2, 3};
        int[] indexArr = new int[arr.length];

        for (int i = 0; i < arr.length; i++) {
            int count = 0;
            for (int j = 0; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    count++;
                }
            }
            indexArr[i] = count;
        }

        for (int i = 0; i < indexArr.length; i++) {
            System.out.println(indexArr[i]);
        }

        /*int a[] = {1,3,2,8,5,4,6,7,9};
        int b[] = new int[10];

        Arrays.fill(b,0);

        for(int i=0;i<a.length;i++){
            b[a[i]] = a[i];
        }

        int cnt=0;
        int c[] = new int[9];
        for(int j=0;j<a.length;j++){
            //b中 a[j]在数组b中的索引位置
            int x = a[j];
            for(int k=0;k<x;k++){
                if(b[k] != 0) {
                    cnt ++;
                }
            }
            c[j] = cnt;
            cnt = 0;
        }*/

        System.out.println(Arrays.toString(indexArr));
    }
}
